/**
 * Copyright (c) 2015-2030 by Beijing Yanlight Co., Ltd.
 * All rights reserved.
 */
package com.yanlight.app.request;

import com.yanlight.Constants;
import com.yanlight.type.BooleanType;

/**
 * 
 * @author haolw
 * @time 2017/08/18
 */
public class PageRequest {
	private Integer pageSize;
	private int currentPageIndex = 1;
	private int page = BooleanType.TRUE.ordinal();

	public Integer getPageSize() {
		return pageSize == null ? Constants.DEFAULT_PAGE_SIZE : pageSize;
	}

	public void setPageSize(Integer pageSize) {
		this.pageSize = pageSize;
	}

	public int getCurrentPageIndex() {
		return currentPageIndex;
	}

	public void setCurrentPageIndex(int currentPageIndex) {
		this.currentPageIndex = currentPageIndex;
	}

	public int getPage() {
		return page;
	}

	public void setPage(int page) {
		this.page = page;
	}

	public Integer getRecordStart() {
		if (BooleanType.TRUE.ordinal() == page) {
			return (currentPageIndex - 1) * getPageSize();
		}
		return null;
	}
}
